

import inspect
import sys,os,time
p=os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
p=os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(p))))
p=p+os.sep+'_base_tool'+os.sep+'python'
sys.path.append(p)
from base_class1_0 import base_class # type: ignore
import tornado.ioloop  
import tornado.web  
import json as JSON
class a_1_0_2_2_0(base_class):
    def run(self,tornado_self,text='None',jpg="None",json="None",**kwargs):
        if text not in ['','None',None]:
            print("text",text)
            tornado_self.write(text)
        elif jpg not in ['','None',None]: 
            tornado_self.set_header("Content-Type", "image/jpeg")  
            print("jpg",jpg)
            tornado_self.write(jpg)  
        elif json not in ['','None',None]:
            print("json",json,type(json))
            if isinstance(json,str):
            
                tornado_self.write(JSON.loads(json))
            else:
                
                tornado_self.write(json)
        else:
            print('{"type":"ok"}',{"type":"ok"})
            tornado_self.write({"type":"ok"})